<template>
  <view class="file_list">
    <view v-for="(ele, index) in fileList" :key="index" class="file_item">
      <view class="left_fileName" @tap="handlePrevFile(ele)">
        {{ ele.originalName }}
      </view>
      <text
        @tap="deleteFile(index)"
        v-if="closeShow"
        class="closeIcon iconfont icon-guanbishixin"
      ></text>
    </view>
  </view>
</template>
<script setup>
import { viewFile } from "@/utils/common";
const $emit = defineEmits(["delFileItem"]);
const props = defineProps({
  fileList: {},
  closeShow: {
    type: Boolean,
    default: true,
  },
  type: {
    type: Number,
    default: 0,
  },
});
const handlePrevFile = (row) => {
  viewFile(row);
};
const deleteFile = (index) => {
  // props.fileList.splice(index, 1)
  $emit("delFileItem", index, props.type);
};
</script>

<style scoped lang="scss">
.file_list {
  .file_item {
    position: relative;
    height: 60rpx;
    width: 78%;
    margin: 10rpx 0;
    line-height: 60rpx;
    padding-right: 80rpx;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-bottom: 1rpx solid #f5f5f5;
    color: #0d80d7;
    font-size: 28rpx;
    .left_fileName {
      overflow: hidden;
      text-overflow: ellipsis; //文本溢出显示省略号
      white-space: nowrap; //文本不会换行
    }

    .closeIcon {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      right: 5rpx;
      font-size: 50rpx;
      color: #333;
    }
  }
}
</style>
